#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{

    
    pid_t id = fork();
    if(id==0)
    {
        //子进程
       
        printf("I am a child_process, pid is: %d , ppid is: %d\n",getpid(),getppid());
        char* myargv[]={"otherExe","-a","-b","-c",NULL};
        char * myenv[]={"HELLO=1234","YANG=FERTILIZER",NULL};
        execvpe("./otherExe",myargv,myenv);

    }
    //父进程
    pid_t ret = waitpid(id,NULL,0);
    if(ret>0)
    {
        printf("wait success, father pid: %d, ret id: %d\n", getpid(), ret);
    }
   // int status;
   // pid_t ret = waitpid(id,&status,0); 
   // if(ret > 0) 
   // { 
   //     if(WIFEXITED(status)) 
   //     {
   //         printf("子进程 %d 正常退出，退出码：%d\n", getpid(), WEXITSTATUS(status));
   //     }
   //     else if(WIFSIGNALED(status))
   //     {
   //          printf("子进程 %d 被信号 %d 终止\n", getpid(), WTERMSIG(status));
   //     }
   // }
    return 0;

}
